For example, as a pretreatment of an OCR (Optical Character Reader), binarization must be carried out, that is, characters written on a paper are read by a camera or a scanner as image data having multiple gray levels not less than three, i.e., as a gray-scale image, and thereafter, the image is separated into a character area and a background area. In this case, using a predetermined threshold value as a reference, a portion having a gray level larger than the threshold value, i.e., a light portion, is converted into “1” as a paper area to be a background, and a portion having a gray level equal to or smaller than the threshold value, i.e., a dark portion, is converted into “0” as a paper area. In this method, however, uneven lighting or the like may cause a portion of the background area to be “0” and undesirably recognized as a character area, resulting in inaccurate reading of the characters.
Further, the method of separating an object image from a background image by binarizing a multiple gray-level image as described above is used for separating shot objects such as bacteria from a microscope image to determine the positions or number of bacteria. FIG. 2 shows an original image 201 having multiple gray-levels, which is obtained by shooting a microscope image with a digital camera, a target binarized image 205 to be obtained by binarizing the original image 201, and a binarized image 206 obtained by binarizing the original image 201 by a conventional method using a fixed threshold value.
The original image 201 is an image having 256 levels of gray per pixel. The left portion of the image 201 is dark due to uneven lighting. There are bacteria 202 to 204 on the original image 201, and it is an object to obtain an image in which the positions or number of the bacteria can be determined, i.e., a binarized image 205 in which the bacteria are separated from the background. However, when the original image 201 is binarized using a fixed threshold value, for example, when, using “128” as a threshold value, pixels of the original image 201 larger than “128” are replaced with white while pixels equal to or smaller than “128” are replaced with black, the binarized image 206 shown in FIG. 2 is obtained.
In the binarized image 206, since the bacterium 203 is equal to or smaller than the threshold value “128” and the neighboring pixels are larger than the threshold value “128”, the bacterium 203 is normally detected. However, since the right portion of the image is dark, the background becomes to have a value smaller than the threshold value on the right side of the image, and both of the bacterium and the background are black, and the bacterium 204 is buried in the background. Conversely, since the bacterium 202 is irradiated with a strong light, it becomes to have a value larger than the threshold value and turns to white. As a result, it becomes difficult to separate the shot objects such as bacteria from the background to obtain accurate positions or number of the bacteria.
As a countermeasure against this problem, there is proposed a method of dividing an image into local areas, and determining a specific threshold value for each local area on the basis of the average of the local areas (for example, refer to Japanese Patent No. 3240389).
In the conventional image processing method constructed as described above, a threshold value is independently determined for each local area to solve the problem that is caused by using a single threshold value for binarization. However, since the threshold value is determined on the basis of the average of the luminance values of the local areas, the average luminance value becomes small in an area where the density of objects to be separated from the background is high, and a lower threshold value is set, that is, an appropriate threshold value cannot be obtained, resulting in a possibility that a desired binarized image cannot be obtained.